(*---------------------------------------------------------------------------
    :Program.    IFFLib.def
    :Author.     Fridtjof Siebert
    :Address.    Nobileweg 67, D-7-Stgt-40
    :Shortcut.   [fbs]
    :Version.    1.0
    :Date.       25-Feb-89
    :Copyright.  PD
    :Language.   Modula-II
    :Translator. M2Amiga v3.1d
                 converted 5.6.92 to V4.096 by Stefan Koehle
    :Imports.    IFFLib [fbs]/Christian A. Weber
    :Contents.   M2 Library module for the iff.library
    :Remark.     You must copy Christian Weber's iff.library to your LIBS:.
---------------------------------------------------------------------------*)

DEFINITION MODULE IFFLib {"iff.library",15};

FROM SYSTEM   IMPORT ADDRESS;
FROM GraphicsD IMPORT ViewModeSet, BitMapPtr;

CONST
  iffname = "iff.library";
  iffversion = 15;          (* Current library version *)


(************** E R R O R - C O D E S ***********************************)

  iffBadTask            = -1;       (* IffError() called by wrong task *)

  iffCantOpenFile       = 16;       (* File not found *)
  iffReadError          = 17;       (* Error reading file *)
  iffNoMem              = 18;       (* Not enough memory *)
  iffNotIFF             = 19;       (* File is not an IFF file *)
  iffWriteError         = 20;       (* Error writing file *)

  iffNoILBM             = 24;       (* IFF file is not of type ILBM *)
  iffNoBMHD             = 25;       (* BMHD chunk not found *)
  iffNoBODY             = 26;       (* BODY chunk not found *)
  iffTooManyPlanes      = 27;       (* BODY has more planes than BitMap *)
  iffUnknownCompression = 28;       (* Unknown compression type *)


(************** S T R U C T U R E S *************************************)

TYPE
  ChunkPtr = POINTER TO Chunk;
  Chunk = RECORD
    ckID: LONGINT;
    ckSize: LONGINT;
    ckData: ARRAY [0..999999] OF SHORTINT; (* ARRAY [0..ckSize] OF SHORTINT *)
  END;

  BitMapHeaderPtr = POINTER TO BitMapHeader;
  BitMapHeader = RECORD
    w,h: CARDINAL;
    x,y: INTEGER;
    nPlanes: SHORTINT;
    masking: SHORTINT;
    compression: SHORTINT;
    pad1: SHORTINT;
    transparentColor: CARDINAL;
    xAspect,yAspect: SHORTINT;
    pageWidth,pageHeight: INTEGER;
  END;

(************** F L A G S   F O R  S a v e B i t M a p ()  **************)

  SaveIFFFlags = (cmpByteRun1,sf1,sf2,sf3,sf4,sf5,sf6,saveHAM,sf8);
  SaveIFFFlagSet = SET OF SaveIFFFlags;

(* Set cmpByteRun1 to create compressed file.  *)
(* Set saveHAM to save HAM Pictures.           *)


(************** F U N C T I O N   D E C L A R A T I O N S ***************)

PROCEDURE OpenIFF(name{8}: ADDRESS): ADDRESS;               CODE - 30;
PROCEDURE CloseIFF(ifffile{9}: ADDRESS);                    CODE - 36;
PROCEDURE FindChunk(ifffile{9}: ADDRESS;
                    name{0}: ADDRESS): ChunkPtr;            CODE - 42;
PROCEDURE GetBMHD(ifffile{9}: ADDRESS): BitMapHeaderPtr;    CODE - 48;
PROCEDURE GetColorMap(ifffile{9}: ADDRESS;
                      colorTable{8}: ADDRESS): LONGINT;     CODE - 54;
PROCEDURE DecodePic(ifffile{9}: ADDRESS;
                    bitmap{8}: BitMapPtr): BOOLEAN;         CODE - 60;
PROCEDURE SaveBitMap(filename{8}: ADDRESS;
                     bitMap{9}: BitMapPtr;
                     colorTable{10}: ADDRESS;
                     flags{0}: SaveIFFFlagSet): BOOLEAN;    CODE - 66;
PROCEDURE SaveClip(filename{8}: ADDRESS;
                   bitmap{9}: BitMapPtr;
                   coltab{10}: ADDRESS;
                   flags{0}: SaveIFFFlagSet;
                   xoff{1},yoff{2}: INTEGER;
                   width{3},height{4}: INTEGER): BOOLEAN;   CODE - 72;
PROCEDURE IffError(): INTEGER;                              CODE - 78;
PROCEDURE GetViewModes(ifffile{9}: ADDRESS): ViewModeSet;   CODE - 84;

END IFFLib.
